Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate use of v1 tasks within v2 workflows #1721

Merged

Conversation

tcompa
Copy link
Collaborator

@tcompa tcompa commented Sep 3, 2024

This cannot be merged&released until we verify that production instances do not include any such task (see script in #1712).

closes #1722

Checklist before merging

  • Update Fix migration for sqlite #1722
  • Test migration failure when there was still some legacy task in v2 workflows
  • I checked all FIXME 1712 entries
  • I added an appropriate entry to CHANGELOG.md
  • I added logging to new code - if appropriate.
  • I merged main into the current branch.

@tcompa tcompa linked an issue Sep 3, 2024 that may be closed by this pull request
@tcompa
Copy link
Collaborator Author

tcompa commented Sep 3, 2024

Note that the CI currently fails because of sqlite:

NotImplementedError: No support for ALTER of constraints in SQLite dialect. Please refer to the batch mode feature which allows for SQLite migrations using a copy-and-move strategy.

Copy link

github-actions bot commented Sep 3, 2024

Benchmark comparison

GET /api/alive/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 1.1 0.8 1.38 0.0 0.0
power 0.9 0.8 1.12 0.0 0.0
dataset 0.8 0.8 1.00 0.0 0.0
project 1.0 0.8 1.25 0.0 0.0
job 0.8 0.8 1.00 0.0 0.0

GET /api/v2/dataset/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 9.7 9.6 1.01 0.6 0.7
power 410.8 420.2 0.98 389.0 440.2
dataset 164.1 165.6 0.99 145.6 171.2
project 49.3 50.8 0.97 50.9 58.9
job 27.8 30.2 0.92 35.3 41.7

GET /api/v2/job/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 6.0 5.7 1.05 2.2 2.2
power 141.6 134.7 1.05 652.0 652.0
dataset 151.4 140.5 1.08 904.8 904.8
project 49.0 45.9 1.07 283.7 283.7
job 41.5 40.0 1.04 224.8 224.8

GET /api/v2/project/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 9.0 6.1 1.48 0.1 0.1
power 9.6 5.6 1.71 0.1 0.1
dataset 8.8 6.0 1.47 0.1 0.1
project 12.6 8.3 1.52 2.3 2.3
job 9.3 5.9 1.58 0.1 0.1

GET /api/v2/workflow/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 19.0 10.8 1.76 0.8 0.8
power 30.2 24.8 1.22 27.2 29.8
dataset 21.3 18.8 1.13 15.8 17.1
project 23.1 22.7 1.02 19.9 21.5
job 12.6 10.2 1.24 0.8 0.9

POST /api/v2/project/3/dataset/403/images/query/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
dataset 160.5 146.7 1.09 275.1 275.1

GET /auth/current-user/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 4.9 4.3 1.14 0.2 0.2
power 4.5 4.2 1.07 0.2 0.2
dataset 4.2 4.1 1.02 0.2 0.2
project 4.2 4.1 1.02 0.2 0.2
job 4.2 4.1 1.02 0.2 0.2

POST /auth/token/login/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
dataset 262.5 258.3 1.02 0.2 0.2

@tcompa
Copy link
Collaborator Author

tcompa commented Sep 9, 2024

For my understanding: Do we need to remove V1 legacy tasks from Fractal server or can we still have them there in old workflows, just without the possibility of running them?

The first one you said: we cannot have V1 tasks linked to V2 tasks any more. Because this action is required, we are completing this PR but we will not merge&release it until the relevant instances are ready.

If we go for an option where we need to first remove them from all workflows, I think it's doable. There are some 30-40 workflows on the Liberali server with V1 legacy tasks, we could manually replace them with the V2 version of the task in each workflow (e.g. download the json parameters of the task, add the new version, upload the parameters there)

Yes, this would the preferred approach. The script from #1712 should let you identify the workflows quickly, but then the legacy-task replacement has to be manual. We can also prepare a script for performing this kind of replacements, if that is useful, although it's TBD whether it would actually save us time.

@jluethi
Copy link
Collaborator

jluethi commented Sep 9, 2024

Yes, this would the preferred approach. The script from #1712 should let you identify the workflows quickly, but then the legacy-task replacement has to be manual. We can also prepare a script for performing this kind of replacements, if that is useful, although it's TBD whether it would actually save us time.

I think we'll be able to do this manually within an hour or 2, so no need for a script. It's not optimal that we have to change old workflows, but I agree that the trade-off here is worth it.

I'll do this at FMI & can also handle it at UZH once the Ilastik task has been tested & verified :)

@jluethi
Copy link
Collaborator

jluethi commented Sep 9, 2024

All legacy tasks in V2 workflows have now been removed from both servers :)

@ychiucco
Copy link
Collaborator

The migration added by this PR will fail (here) if performed on a database with a legacy Task in a WorkflowV2.


Test:

  • Switch to main and create a DB such that
select is_legacy_task from workflowtaskv2;

is_legacy_task
----------------
 f
 t
(2 rows)
  • Switch to 1712-on-hold-deprecate-use-of-v1-tasks-within-v2-workflows and run fractalctl set-db:
WARNING:root:FRACTAL_TASKS_DIR="tasks" is not an absolute path; converting it to "/Users/yuri/Desktop/eXact/fractal/fractal-server/tasks"
WARNING:root:FRACTAL_RUNNER_WORKING_BASE_DIR="artifacts" is not an absolute path; converting it to "/Users/yuri/Desktop/eXact/fractal/fractal-server/artifacts"
START: Run alembic.config, with argv=['-c', '/Users/yuri/Desktop/eXact/fractal/fractal-server/fractal_server/alembic.ini', 'upgrade', 'head']
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 091b01f51f88 -> d9a140db5d42, Remove link between v1 and v2 tasks/workflowtasks tables
Traceback (most recent call last):
...
...
asyncpg.exceptions.NotNullViolationError: column "task_id" of relation "workflowtaskv2" contains null values

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
...
...

sqlalchemy.exc.IntegrityError: (sqlalchemy.dialects.postgresql.asyncpg.IntegrityError) <class 'asyncpg.exceptions.NotNullViolationError'>: column "task_id" of relation "workflowtaskv2" contains null values
[SQL: ALTER TABLE workflowtaskv2 ALTER COLUMN task_id SET NOT NULL]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
  • Remove the legacy Task from the WorkflowV2, i.e.
select is_legacy_task from workflowtaskv2;

is_legacy_task
----------------
 f
(1 row)
  • Run again fractalctl set-db:
WARNING:root:FRACTAL_TASKS_DIR="tasks" is not an absolute path; converting it to "/Users/yuri/Desktop/eXact/fractal/fractal-server/tasks"
WARNING:root:FRACTAL_RUNNER_WORKING_BASE_DIR="artifacts" is not an absolute path; converting it to "/Users/yuri/Desktop/eXact/fractal/fractal-server/artifacts"
START: Run alembic.config, with argv=['-c', '/Users/yuri/Desktop/eXact/fractal/fractal-server/fractal_server/alembic.ini', 'upgrade', 'head']
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 091b01f51f88 -> d9a140db5d42, Remove link between v1 and v2 tasks/workflowtasks tables
END: alembic.config

START: Default group creation
END: Default group creation

START: First user creation
END: First user creation

@tcompa tcompa changed the title [DO NOT MERGE] Deprecate use of v1 tasks within v2 workflows Deprecate use of v1 tasks within v2 workflows Sep 13, 2024
@tcompa tcompa marked this pull request as ready for review September 13, 2024 11:26
@tcompa tcompa merged commit f365226 into main Sep 13, 2024
20 checks passed
@tcompa tcompa deleted the 1712-on-hold-deprecate-use-of-v1-tasks-within-v2-workflows branch September 13, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix migration for sqlite Deprecate use of V1 tasks within V2 workflows
3 participants